<?php	
if ( ! isset( $content_width ) ) $content_width = 900;

//------ Translation text domain ------//
load_theme_textdomain( 'unicorn', get_template_directory().'/languages' );
$locale = get_locale();
$locale_file = get_template_directory().'/languages/$locale.php';
if ( is_readable($locale_file) )
require_once($locale_file);

//------ THEME OPTIONS PANEL ------//
require_once('reedwan-options/options-init.php');

//------ CUSTOM METABOXES ------//
require_once('functions/metaboxes/metaboxes.php');
require_once('functions/metaboxes/post-metaboxes.php');

//------ CUSTOM TAX META ------//
require_once ('functions/taxmeta/class-usage.php');

//--- SHORTCODES ------//
require_once ('functions/shortcodes/shortcodes.php');

//------ PAGINATION ------//
require_once('functions/pagination.php');

//------ SIDEBARS ------//
require_once('functions/sidebars.php');

//------ RELATED POSTS ------//
require_once('functions/related-posts.php');

//------ PROFILE ------//
require_once('functions/profile.php');

//------ COMMENTS ------//
require_once('functions/comments.php');

//------ THUMBNAILS ------//
require_once('functions/thumbnails.php');

//------ Post Views Count ------//
require_once('functions/post-views-count.php');

//------ Custom dropdown menu ------//
include_once('functions/dropdown-menus.php'); 

//------ GALLERY SHORTCODES STYLE ------//
require_once('functions/gallery.php');



//------ PLUGINS ------//
require_once('functions/plugins/socialbox/socialbox.php');
require_once('functions/plugins/dp-flickr-widget/dp-flickr-widget.php');
require_once('functions/plugins/google-badge-connect-direct/google_plus_badge_direct_connect.php');
require_once('functions/plugins/wickett-twitter-widget/wickett-twitter-widget.php');
require_once('functions/plugins/ninety-login/ninety-login.php');

//------ WIDGETS ------//
require_once('functions/widgets/facebook-like-widget.php');
require_once('functions/widgets/video-widget.php');
require_once('functions/widgets/column-magazine-1.php');
require_once('functions/widgets/column-magazine-2.php');
require_once('functions/widgets/column-magazine-3.php');
require_once('functions/widgets/recent-posts-widget.php');
require_once('functions/widgets/comment-widget.php');
require_once('functions/widgets/popular-posts.php');
require_once('functions/widgets/adds300x250.php');
require_once('functions/widgets/adds468x60.php');
require_once('functions/widgets/adds728x90.php');
require_once('functions/widgets/adds125x125.php');
require_once('functions/widgets/search-widget.php');
require_once('functions/widgets/social-widget.php');

//------ Featured Images (post thumbnail) ------//
add_theme_support( 'post-thumbnails' );
  
//------ Add default posts and comments RSS feed links to <head> section ------//
add_theme_support( 'automatic-feed-links' );

//------ WP menus ------//
register_nav_menu('topNav', __('Top Navigation', 'unicorn'));
register_nav_menu('mainNav', __('Main Navigation', 'unicorn')); 
register_nav_menu('bottomNav', __('Bottom Navigation', 'unicorn'));  
  
  
//------ Post Formats ------//
add_theme_support( 'post-formats', array( 'video', 'audio', 'gallery' ) );


//------ Search Filter ------//
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type',  array( 'post'));
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');

//------ Limit Word ------//
function string_limit_words($string, $word_limit)
    { 
  $words = explode(' ', $string, ($word_limit + 1));
  if(count($words) > $word_limit)
  array_pop($words);
  return implode(' ', $words) . '...';
}

// ------ Get rid of the font-size on the tagcloud widget ------//
add_filter( "widget_tag_cloud_args", 'my_widget_tag_cloud_args' );
function my_widget_tag_cloud_args( $args ) {
	$args['number'] = 12;
	$args['largest'] = 12;
	$args['smallest'] = 12;
	$args['number'] = 30;
	$args['format'] = 'list';
	$args['unit'] = 'px';
	return $args;
}
// ------ Metaboxes Command ------//
function rd_metabox_scripts() {
  wp_register_script('my-upload', get_template_directory_uri().'/functions/js/my_upload.js', array('jquery','media-upload','thickbox'));
  wp_register_script('metaboxes', get_template_directory_uri().'/functions/js/metaboxes_scripts.js', 'jquery');
  wp_register_script('clone-field', get_template_directory_uri().'/functions/js/jquery.dynamicField-1.0.js', 'jquery');

    
  wp_enqueue_script('media-upload');
  wp_enqueue_script('thickbox');
  wp_enqueue_script('my-upload');
  wp_enqueue_script('metaboxes');
  wp_enqueue_script('clone-field');

}    
add_action('admin_print_scripts-post-new.php', 'rd_metabox_scripts');
add_action('admin_print_scripts-post.php', 'rd_metabox_scripts');

function rd_metabox_styles() {
    wp_register_style('metaboxes', get_template_directory_uri() . '/functions/css/metaboxes_styles.css');
    wp_enqueue_style('thickbox');
    wp_enqueue_style('metaboxes');
}
add_action('admin_print_styles-post-new.php', 'rd_metabox_styles');
add_action('admin_print_styles-post.php', 'rd_metabox_styles');

// ------ Unregister Default Widget ------//
function unregister_default_wp_widgets() {
    unregister_widget('WP_Widget_Recent_Comments');
	unregister_widget('WP_Widget_Search');
}
add_action('widgets_init', 'unregister_default_wp_widgets', 1);
 

// ------ Register Script ------//

function reedwan_register_js() {
	if (!is_admin()) {
		wp_register_script('jqueryUI', get_template_directory_uri().'/js/jquery-ui.js', array("jquery"), true );
		wp_register_script('RoyalSlider', get_template_directory_uri().'/js/jquery.royalslider.min.js', array("jquery"), true );
		wp_register_script('FlexSlider', get_template_directory_uri().'/js/jquery.flexslider-min.js', array("jquery"), true );
		wp_register_script('NewsTicker', get_template_directory_uri().'/js/newsticker.jquery.min.js', array("jquery"), true );
		wp_register_script('backstretch', get_template_directory_uri().'/js/jquery.backstretch.min.js', array("jquery"), true );
		wp_register_script('tabber', get_template_directory_uri().'/', 'js/tabber.js', array("jquery"), true );
		wp_register_script('prettyPhoto', get_template_directory_uri().'/js/jquery.prettyPhoto.js', array("jquery"), true );
		wp_register_script('ScrollTop', get_template_directory_uri().'/js/scrolltopcontrol.js', array("jquery"), true );
		wp_register_script('Custom', get_template_directory_uri().'/js/custom.js', array("jquery"), true);
		
		wp_register_script('hoverintent', get_template_directory_uri() . '/js/hoverIntent.js');    
		wp_register_script('superfish',   get_template_directory_uri() . '/js/superfish.js', array( 'jquery', 'hoverintent' ));  
		wp_register_script('supersubs',   get_template_directory_uri() . '/js/supersubs.js', array( 'superfish' ));  
		wp_enqueue_script('jquery');
		wp_enqueue_script('supersubs');
		wp_enqueue_script('jqueryUI');
		wp_enqueue_script('RoyalSlider');
		wp_enqueue_script('FlexSlider');
		wp_enqueue_script('NewsTicker');
		wp_enqueue_script('backstretch');
		wp_enqueue_script('prettyPhoto');
		wp_enqueue_script('ScrollTop');
		wp_enqueue_script('Custom');

	}
}
add_action('init', 'reedwan_register_js');

// ------ Register Style ------//
function reedwan_register_style() {
	if (!is_admin()) {
		wp_register_style('reset', get_template_directory_uri() . '/css/reset.css');
		wp_register_style('text', get_template_directory_uri() . '/css/text.css');
		wp_register_style('style', get_template_directory_uri() . '/style.css');
		wp_register_style('flexslider', get_template_directory_uri() . '/css/flexslider.css');
		wp_register_style('royalslider', get_template_directory_uri() . '/css/royalslider.css');
		wp_register_style('rs_default', get_template_directory_uri() . '/css/rs-default.css');
		wp_register_style('ticker', get_template_directory_uri() . '/css/ticker.css');
		wp_register_style('prettyPhoto', get_template_directory_uri() . '/css/prettyPhoto.css');
		wp_register_style('superfishbase',   get_template_directory_uri() . '/css/superfish.css'); 
		wp_register_style('responsive', get_template_directory_uri() . '/css/responsive.css');
		wp_register_style('oswald', get_template_directory_uri() . '/css/oswald/stylesheet.css');
		wp_register_style('custom', stripslashes (get_option('reedwan_codechildcss')));
	
		
		wp_enqueue_style('reset');
		wp_enqueue_style('text');
		wp_enqueue_style('style');
		wp_enqueue_style('superfishbase');  
		wp_enqueue_style('flexslider');
		wp_enqueue_style('royalslider');
		wp_enqueue_style('rs_default');
		wp_enqueue_style('ticker');
		wp_enqueue_style('prettyPhoto');
		wp_enqueue_style('oswald');
		if(get_option('reedwan_responsive_layout') == 'true')
		{
			wp_enqueue_style('responsive');
		}
		
		if(get_option('reedwan_code_allow_childcss') == 'true')
		{
			wp_enqueue_style('custom');
		}
		
		
	}
}
add_action('init', 'reedwan_register_style');



function header_style()
{
		if(get_option('reedwan_content_font_custom_enable') == 'true') {
			echo stripslashes(get_option('reedwan_content_font_custom_link'));
		}
		if(get_option('reedwan_heading_font_custom_enable') == 'true') { 
			echo stripslashes(get_option('reedwan_heading_font_custom_link'));
		}
		if(get_option('reedwan_topnav_font_custom_enable') == 'true') { 
				echo stripslashes(get_option('reedwan_topnav_font_custom_link'));
		}
		if(get_option('reedwan_mainnav_font_custom_enable') == 'true') { 
				echo stripslashes(get_option('reedwan_mainnav_font_custom_link'));
		}
		if(get_option('reedwan_bottomnav_font_custom_enable') == 'true') { 
			echo stripslashes(get_option('reedwan_bottomnav_font_custom_link'));
		}
		require_once('options.php');
}
add_action('wp_head', 'header_style');
?>